﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>ProClinic-医院管理系统Bootstrap4前端框架</title>
    <!-- Fav  Icon Link -->
    <link rel="shortcut icon" type="image/png" href="images/fav.png">
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- themify icons CSS -->
    <link rel="stylesheet" href="css/themify-icons.css">
    <!-- Animations CSS -->
    <link rel="stylesheet" href="css/animate.css">
    <!-- Main CSS -->
    <link rel="stylesheet" href="css/styles.css">
    <link rel="stylesheet" href="css/green.css" id="style_theme">
    <link rel="stylesheet" href="css/responsive.css">
    <!-- morris charts -->
    <link rel="stylesheet" href="charts/css/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet" href="css/jquery-jvectormap.css">
    <link rel="stylesheet" href="datatable/dataTables.bootstrap4.min.css">

    <script src="js/modernizr.min.js"></script>
</head>

<body>
<!-- Pre Loader -->
<div class="loading">
    <div class="spinner">
        <div class="double-bounce1"></div>
        <div class="double-bounce2"></div>
    </div>
</div>
<!--/Pre Loader -->
<!-- Color Changer -->
<div class="theme-settings" id="switcher">
		<span class="theme-click">
			<span class="ti-settings"></span>
		</span>
    <span class="theme-color theme-default theme-active" data-color="green"></span>
    <span class="theme-color theme-blue" data-color="blue"></span>
    <span class="theme-color theme-red" data-color="red"></span>
    <span class="theme-color theme-violet" data-color="violet"></span>
    <span class="theme-color theme-yellow" data-color="yellow"></span>
</div>
<!-- /Color Changer -->
<div class="wrapper">
    <!-- Page Content -->
    <div id="content">
        <!-- Top Navigation -->
        <div class="container top-brand">
            <nav class="navbar navbar-default">
                <div class="navbar-header">
                    <div class="sidebar-header"><a href="index.html"><img src="images/logo-dark.png" class="logo"
                                                                          alt="logo"></a>
                    </div>
                </div>
                <ul class="nav justify-content-end">
                    <li class="nav-item">
                        <a class="nav-link">
                            <span title="Fullscreen" class="ti-fullscreen fullscreen"></span>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="modal" data-target=".lochana-modal-lg">
                            <span class="ti-search"></span>
                        </a>
                        <div class="modal fade lochana-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
                            <div class="modal-dialog modal-lorvens">
                                <div class="modal-content lochana-box-shadow2">
                                    <div class="modal-header">
                                        <h5 class="modal-title">Search Patient/医生:</h5>
                                        <span class="ti-close" data-dismiss="modal" aria-label="Close">
												</span>
                                    </div>
                                    <div class="modal-body">
                                        <form>
                                            <div class="form-group">
                                                <input type="text" class="form-control" id="search-term"
                                                       placeholder="Type text here">
                                                <button type="button" class="btn btn-lorvens lochana-bg">
                                                    <span class="ti-location-arrow"></span> Search
                                                </button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
                           aria-haspopup="true"
                           aria-expanded="false">
                            <span class="ti-announcement"></span>
                        </a>
                        <div class="dropdown-menu lochana-box-shadow2 notifications animated flipInY">
                            <h5>Notifications</h5>
                            <a class="dropdown-item" href="#">
                                <span class="ti-wheelchair"></span> New Patient Added</a>
                            <a class="dropdown-item" href="#">
                                <span class="ti-money"></span> Patient payment done</a>
                            <a class="dropdown-item" href="#">
                                <span class="ti-time"></span>Patient Appointment booked</a>
                            <a class="dropdown-item" href="#">
                                <span class="ti-wheelchair"></span> New Patient Added</a>
                        </div>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
                           aria-haspopup="true"
                           aria-expanded="false">
                            <span class="ti-user"></span>
                        </a>
                        <div class="dropdown-menu lochana-box-shadow2 profile animated flipInY">
                            <h5>John Willing</h5>
                            <a class="dropdown-item" href="#">
                                <span class="ti-settings"></span> Settings</a>
                            <a class="dropdown-item" href="#">
                                <span class="ti-help-alt"></span> Help</a>
                            <a class="dropdown-item" href="#">
                                <span class="ti-power-off"></span> Logout</a>
                        </div>
                    </li>
                </ul>

            </nav>
        </div>
        <!-- /Top Navigation -->
        <!-- Menu -->
        <div class="container menu-nav">
            <nav class="navbar navbar-expand-lg lochana-bg text-white">
                <button class="navbar-toggler" type="button" data-toggle="collapse"
                        data-target="#navbarSupportedContent"
                        aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="ti-menu text-white"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav mr-auto">
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="true"
                               aria-expanded="false"><span class="ti-home"></span> 控制面板</a>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="index.html">默认</a>
                            </div>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="true"
                               aria-expanded="false"><span class="ti-wheelchair"></span> 病人管理</a>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="add-patient.html">添加病人信息</a>
                                <a class="dropdown-item" href="patients.html">查看病人信息</a>
                                <a class="dropdown-item" href="about-patient.html">病人详情</a>
                                <a class="dropdown-item" href="edit-patient.html">编辑病人信息</a>
                            </div>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="true"
                               aria-expanded="false"><span class="ti-user"></span> 医生管理</a>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="add-doctor.html">添加医生信息</a>
                                <a class="dropdown-item" href="doctors.html">查询医生信息</a>
                                <a class="dropdown-item" href="about-doctor.html">医生信息详情</a>
                                <a class="dropdown-item" href="edit-doctor.html">编辑医生信息</a>
                            </div>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="true"
                               aria-expanded="false"><span class="ti-pencil-alt"></span> 出诊管理</a>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="add-appointment.html">添加出诊信息</a>
                                <a class="dropdown-item" href="appointments.html">查询出诊信息</a>
                                <a class="dropdown-item" href="about-appointment.html">出诊信息详情</a>
                                <a class="dropdown-item" href="edit-appointment.html">编辑出诊信息</a>
                            </div>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="true"
                               aria-expanded="false"><span class="ti-money"></span> 支付管理</a>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="add-payment.html">添加支付</a>
                                <a class="dropdown-item" href="payments.html">所有支付</a>
                                <a class="dropdown-item" href="about-payment.html">发票</a>
                            </div>
                        </li>
                        <li class="nav-item dropdown active">
                            <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="true"
                               aria-expanded="false"><span class="ti-key"></span> 病房分配</a>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="add-room.html">添加病房</a>
                                <a class="dropdown-item" href="rooms.html">查询病房</a>
                                <a class="dropdown-item" href="edit-room.html">编辑病房信息</a>
                            </div>
                        </li>

                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="true"
                               aria-expanded="false"><span class="ti-file"></span> 其它页面</a>
                            <div class="dropdown-menu">
                                <a class="dropdown-item" href="login.html">登录</a>
                                <a class="dropdown-item" href="sign-up.html">注册</a>
                                <a class="dropdown-item" href="404.html">404</a>
                                <a class="dropdown-item" href="blank-page.html">空白页</a>
                                <a class="dropdown-item" href="pricing.html">价格表</a>
                                <a class="dropdown-item" href="faq.html">FAQ</a>
                                <a class="dropdown-item" href="invoice.html">发票</a>
                            </div>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
        <!-- /Menu -->
        <!-- Breadcrumb -->
        <!-- Page Title -->
        <div class="container mt-0">
            <div class="row breadcrumb-bar">
                <div class="col-md-6">
                    <h3 class="block-title">Allotments</h3>
                </div>
                <div class="col-md-6">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="index.html">
                                <span class="ti-home"></span>
                            </a>
                        </li>
                        <li class="breadcrumb-item">Allotments</li>
                        <li class="breadcrumb-item active">All Allotments</li>
                    </ol>
                </div>
            </div>
        </div>
        <!-- /Page Title -->

        <!-- /Breadcrumb -->
        <!-- Main Content -->
        <div class="container">

            <div class="row">
                <!-- Widget Item -->
                <div class="col-md-12">
                    <div class="widget-area-2 lochana-box-shadow">
                        <h3 class="widget-title">Allotments list</h3>
                        <div class="table-responsive mb-3">
                            <div id="tableId_filter" class="dataTables_filter"><label>Search:<input type="search"
                                                                                                    id="Searchs"
                                                                                                    class="form-control form-control-sm"
                                                                                                    placeholder=""
                                                                                                    aria-controls="tableId">
                                <input class="btn btn-primary" type="button" id="Search" value="搜索">
                            </label>
                            </div>
                            <table id="tableId" class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th class="no-sort">
                                        <div class="custom-control custom-checkbox">
                                            <input class="custom-control-input" type="checkbox" id="select-all">
                                            <label class="custom-control-label" for="select-all"></label>
                                        </div>
                                    </th>
                                    <th>病房号</th>
                                    <th>病房类型</th>
                                    <th>病人姓名</th>
                                    <th>住院时间</th>
                                    <th>出院时间</th>
                                    <th>医生姓名</th>
                                    <th>状态</th>
                                </tr>
                                </thead>
                                <tbody id="getlist">

                                <tr>
                                    <td>
                                        <div class="custom-control custom-checkbox">
                                            <input class="custom-control-input" type="checkbox" id="5">
                                            <label class="custom-control-label" for="5"></label>
                                        </div>
                                    </td>
                                    <td>10</td>
                                    <td>Icu</td>
                                    <td>Manoj Kumar</td>
                                    <td>12-11-2018</td>
                                    <td>16-11-2018</td>
                                    <td>Dr Daniel Smith</td>
                                    <td>
                                        <span class="badge badge-success">可出诊</span>
                                    </td>
                                </tr>

                                </tbody>
                            </table>
                            <div class="row">
                                <div class="col-sm-12 col-md-7">
                                    <div class="dataTables_paginate paging_simple_numbers" id="tableId_paginate">
                                        <ul class="pagination" id="pagination">
                                            <li class="paginate_button page-item previous disabled"
                                                id="tableId_previous"><a href="#" aria-controls="tableId"
                                                                         data-dt-idx="0" tabindex="0" class="page-link">上一页</a>
                                            </li>
                                            <li class="paginate_button page-item active"><a href="#"
                                                                                            aria-controls="tableId"
                                                                                            data-dt-idx="1" tabindex="0"
                                                                                            class="page-link">1</a></li>
                                            <li class="paginate_button page-item "><a href="#"
                                                                                      aria-controls="tableId"
                                                                                      data-dt-idx="2" tabindex="0"
                                                                                      class="page-link">2</a></li>
                                            <li class="paginate_button page-item next" id="tableId_next"><a href="#"
                                                                                                            aria-controls="tableId"
                                                                                                            data-dt-idx="3"
                                                                                                            tabindex="0"
                                                                                                            class="page-link">下一页</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <!--Export links-->
                            <nav aria-label="Page navigation example">
                                <ul class="pagination justify-content-center export-pagination">
                                    <li class="page-item">
                                        <a class="page-link" href="#"><span class="ti-download"></span> csv</a>
                                    </li>
                                    <li class="page-item">
                                        <a class="page-link" href="#"><span class="ti-printer"></span> print</a>
                                    </li>
                                    <li class="page-item">
                                        <a class="page-link" href="#"><span class="ti-file"></span> PDF</a>
                                    </li>
                                    <li class="page-item">
                                        <a class="page-link" href="#"><span class="ti-align-justify"></span> Excel</a>
                                    </li>
                                </ul>
                            </nav>
                            <!-- /Export links-->

                            <button type="button" class="btn btn-primary mt-3 mb-0" id="compile"><span
                                    class="ti-pencil-alt"></span>
                                编辑
                            </button>
                        </div>
                    </div>
                </div>
                <!-- /Widget Item -->
            </div>
        </div>
        <!-- /Main Content -->
        <!--Copy Rights-->
        <div class="container">
            <div class="d-sm-flex justify-content-center">
                <span class="text-muted text-center d-block d-sm-inline-block">Copyright © 2020. All rights reserved.</span>
            </div>
        </div>
        <!-- /Copy Rights-->
    </div>
    <!-- /Page Content -->
</div>
<!-- Back to Top -->
<a id="back-to-top" href="#" class="back-to-top">
    <span class="ti-angle-up"></span>
</a>
<!-- /Back to Top -->
<!-- Jquery Library-->
<script src="js/jquery-3.2.1.min.js"></script>
<!-- Popper Library-->
<script src="js/popper.min.js"></script>
<!-- Bootstrap Library-->
<script src="js/bootstrap.min.js"></script>

<!-- Datatable  -->
<!--<script src="datatable/jquery.dataTables.min.js"></script>-->
<!--<script src="datatable/dataTables.bootstrap4.min.js"></script>-->

<!-- Custom Script-->
<script src="js/custom.js"></script>
<script src="js/custom-datatables.js"></script>
<script>

    let pageNum = 1;
    let pageSize = 10;
    let condition = null;
    getlist();

    //编辑跳转
    $(function () {
        $("#compile").click(function () {
            $(".custom-control-input:checked").each(function () {
                let id =$(this).prop("id");
                location.href = "edit-room.html?inhospitalId=" + id + "";
            })
        })
    })

    function getlist() {
        $.ajax({
            type: "GET",
            url: "/inhospital",
            data: {
                pageNum: pageNum,
                pageSize: pageSize,
                condition: condition,
            },
            dataType: "json",
            success: (result, xhr, status) => {
                if (result.data.list.length > 0) {
                    //渲染数据
                    let content = "";
                    //迭代数据
                    $.each(result.data.list, function (index, obj) {
                        content += "<tr>" +
                            "<td>\n" +
                            "                                        <div class=\"custom-control custom-checkbox\">\n" +
                            "                                            <input class=\"custom-control-input\" name=\"selectName\" type=\"checkbox\" id=\"" + obj.inHospitalId + "\">\n" +
                            "                                              <input type='hidden' id='inhospitalId' value='" + obj.inHospitalId + "'>" +
                            "                                            <label class=\"custom-control-label\" for=\"" + obj.inHospitalId + "\"></label>\n" +
                            "                                        </div>\n" +
                            "                                    </td>" +
                            "                                    <td>" + obj.room.roomName + "</td>\n" +
                            "                                    <td>" + obj.room.roomType.typeName + "</td>\n";
                        if (obj.patient.patientName != null) {
                            content += "<td>" + obj.patient.patientName + "</td>\n";
                        } else {
                            content += "<td>-</td>\n";
                        }
                        if (obj.inTime != null) {
                            content += "<td>" + obj.inTime + "</td>\n";
                        } else {
                            content += "<td>-</td>\n";
                        }
                        if (obj.outTime != null) {
                            content += "<td>" + obj.outTime + "</td>\n";
                        } else {
                            content += "<td>-</td>\n";
                        }
                        if (obj.doctor.doctorName != null) {
                            content += "<td>" + obj.doctor.doctorName + "</td>\n"
                        } else {
                            content += "<td>-</td>\n";
                        }
                        if (obj.outTime != null) {
                            content += " <td>\n" +
                                " <span class=\"badge badge-success\">已出院</span>\n" +
                                "</td>\n" +
                                "</tr>";
                        } else {
                            content += " <td>\n" +
                                " <span class=\"badge badge-success\">可出院</span>\n" +
                                "</td>\n" +
                                "</tr>";
                        }


                    });
                    // 更新DOM元素
                    $("#getlist").html(content);
                    let pageContent = "";
                    if (result.data.isFirstPage) {
                        pageContent += "<li class=\"paginate_button page-item previous disabled\"\n" +
                            "           id=\"tableId_previous\">" +
                            "           <a href=\"#\" " +
                            "           aria-controls=\"tableId\"\n" +
                            "           data-dt-idx=\"0\" " +
                            "           tabindex=\"0\" " +
                            "           class=\"page-link\" title=\"上一页\">上一页</a>\n" +
                            "           </li>";
                    } else {
                        pageContent += "<li class=\"paginate_button page-item previous\" " +
                            "           id=\"tableId_previous\">" +
                            "           <a href=\"#\"\n" +
                            "           aria-controls=\"tableId\"\n" +
                            "           data-dt-idx=\"" + result.data.prePage + "\"\n" +
                            "           tabindex=\"0\"\n" +
                            "           class=\"page-link\" title=\"" + result.data.prePage + "\">上一页</a>\n" +
                            "           </li>";
                    }

                    for (let i = 1; i <= result.data.pages; i++) {
                        if (i == result.data.pageNum) {
                            pageContent += "<li class=\"paginate_button page-item active\"><a href=\"#\"\n" +
                                "           aria-controls=\"tableId\"\n" +
                                "           data-dt-idx=\"" + i + "\" tabindex=\"0\"\n" +
                                "           class=\"page-link\" title=\"" + i + "\">" + i + "</a></li>";
                        } else {
                            pageContent += "<li class=\"paginate_button page-item \"><a href=\"#\"\n" +
                                "           aria-controls=\"tableId\"\n" +
                                "           data-dt-idx=\"" + i + "\" tabindex=\"0\"\n" +
                                "           class=\"page-link\" title=\"" + i + "\">" + i + "</a></li>";
                        }
                    }

                    if (result.data.isLastPage) {
                        pageContent += "<li class=\"paginate_button page-item next disabled\" " +
                            "           id=\"tableId_next\">" +
                            "           <a href=\"#\"\n" +
                            "           aria-controls=\"tableId\"\n" +
                            "           data-dt-idx=\"" + result.data.pages + "\"\n" +
                            "           tabindex=\"0\"\n" +
                            "           class=\"page-link\">下一页</a>\n" +
                            "           </li>";
                    } else {
                        pageContent += "<li class=\"paginate_button page-item next\" " +
                            "           id=\"tableId_next\">" +
                            "           <a href=\"#\"\n" +
                            "           aria-controls=\"tableId\"\n" +
                            "           data-dt-idx=\"" + result.data.nextPage + "\"\n" +
                            "           tabindex=\"0\"\n" +
                            "           class=\"page-link\" title=\"" + result.data.nextPage + "\">下一页</a>\n" +
                            "           </li>";
                    }
                    $("#pagination").html(pageContent);
                } else {
                    alert("list fail");
                }
            }

        })
    }

    // 搜索按钮事件
    $(document).on("click", "#Search", function () {
        // 获取输入的关键字
        condition = $("#Searchs").val().trim();

        // 设置页码
        pageNum = 1;
        // 调用查询方法
        getlist();
    });





</script>
</body>

</html>